package fast.mvc;

import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class PlayerPanel extends JPanel {
	
	private static final long serialVersionUID = 852930853916977746L;
	
	String[] professionStrings = { "Leatherworking", "Enchanting", "Engineering", "Jewelcrafting", "Blacksmithing", "Alchemy", "Herbalism", "Skinning", "Mining" };
	String[] raceStrings = { "dwarf", "human", "nightelf", "gnome", "worgen", "undead", "orc", "troll", "bloodelf", "goblin", "pandaren" };
	
	private JComboBox<String> raceList;
	private JComboBox<String> professionList;
	private JComboBox<String> professionList2;
	private JCheckBox glyphVendetta;
	
	public PlayerPanel(String race,String[] professions,List<String> glyphs){
		this.setLayout(null);
		
		JLabel labelRace = new JLabel("Race:");
		labelRace.setBounds(10, 10, 150, 20);
		add(labelRace);
		
		raceList = new JComboBox<String>(raceStrings);
		raceList.setBounds(10, 30, 150, 30);
		raceList.setSelectedItem(race);
		add(raceList);
		
		JLabel labelProfession = new JLabel("Professions:");
		labelProfession.setBounds(10, 70, 150, 20);
		add(labelProfession);
		
		professionList = new JComboBox<String>(professionStrings);
		professionList.setBounds(10, 90, 150, 30);
		professionList.setSelectedItem(professions[0]);
		add(professionList);
		
		professionList2 = new JComboBox<String>(professionStrings);
		professionList2.setBounds(170, 90, 150, 30);
		professionList2.setSelectedItem(professions[1]);
		add(professionList2);
		
		glyphVendetta = new JCheckBox("vendetta");
		glyphVendetta.setBounds(10, 130, 150, 30);
		if(glyphs.contains("vendetta"))
			glyphVendetta.setSelected(true);
		else
			glyphVendetta.setSelected(false);
		add(glyphVendetta);
	}
	
	public void addRaceChangeListener(ActionListener l){
        raceList.addActionListener(l);
    }
	
	public void addProfessionChangeListener(ActionListener l){
		professionList.addActionListener(l);
		professionList2.addActionListener(l);
	}
	
	public void addGlyphChangeListener(ActionListener l){
		glyphVendetta.addActionListener(l);
	}
	
	public List<String> getSelectedProfessions(){
		List<String> pro = new ArrayList<String>();
		pro.add((String) professionList.getSelectedItem());
		pro.add((String) professionList2.getSelectedItem());
		return pro;
	}
}
